<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Highcharts Example</title>
		<!-- JS2CAL -->
	<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/jscal2/jscal2.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/jscal2/border-radius.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/jscal2/gold/gold.css" />
    <script type="text/javascript" src="<?php echo base_url();?>js/jscal2/jscal2.js"></script>
    <script type="text/javascript" src="<?php echo base_url();?>js/jscal2/lang/th.js"></script>
		
		<!-- 1. Add these JavaScript inclusions in the head of your page -->
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
		<script type="text/javascript" src="<?php echo base_url();?>js/highchart/js/highcharts.js"></script>
		
		<!-- 1a) Optional: add a theme file -->
		<!--
			<script type="text/javascript" src="<?php echo base_url();?>js/highchart/js/themes/gray.js"></script>
		-->
		
		<!-- 1b) Optional: the exporting module -->
		<script type="text/javascript" src="<?php echo base_url();?>js/highchart/js/modules/exporting.js"></script>
		
		
		<!-- 2. Add the JavaScript to initialize the chart on document ready -->
		<script type="text/javascript">
		
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container',
						type: 'line'
					},
					title: {
						text: 'Snow depth in the Vikjafjellet mountain, Norway'
					},
					subtitle: {
						text: 'An example of irregular time data in Highcharts JS'	
					},
					xAxis: {
						type: 'datetime',
						dateTimeLabelFormats: { // don't display the dummy year
						second: '%H:%M:%S',
						minute: '%H:%M',
						hour: '%H:%M',
						day: '%e. %b',
						week: '%e. %b',
						month: '%b \'%y',
						year: '%Y'
						}
					},
					yAxis: {
						title: {
							text: 'Snow depth (m)'
						},
						min: 0
					},
					tooltip: {
						formatter: function() {
				                return '<b>'+ this.series.name +'</b><br/>'+
								Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', this.x) +': '+ this.y +' Baht';
						}
					},
					series: [
<?php
		foreach ($dat as $larnname => $arr):
	?>	{
			name: '<?=$larnname;?>',
			
			data: [
			<?php foreach($arr as $dateandtotal): ?>
			
				[<?="{$dateandtotal['dateupload']}";?> , <?=$dateandtotal['total'];?> ],
				
			<?php endforeach;?>
			]
		},
	<?php	
		endforeach;
	?>

					]
				});
				
				
			});
				
		</script>
		
	</head>
	<body>
		
		<!-- 3. Add the container -->
		<div id="container" style="width: 800px; height: 400px; margin: 0 auto"></div>
		
    
    <table>
    	<thead>
    		<tr>
    			<th>Date/time</th>
    			<th>ลาน</th>
    			<th>น้ำหนักทั้งหมด</th>
    			<th>เงินจ่ายสุทธิ</th>
    			<th>เงินโปรโมชั่น</th>
    			<th>เงินจ่าย+โปรโมชั่น</th>
    		</tr>
    	</thead>
    	<tbody>
    		<?php 
    			foreach ($realtimeUpload as $row):
    		?>
    				<tr>
    					<td><?php echo $row['dateupload'];?> </td>
    					<td><?php echo $row['posname'];?> </td>
    					<td><?php echo $row['sum_netwg'];?> </td>
    					<td><?php echo $row['sum_netbuy'];?></td>
    					<td><?php echo $row['sum_promo'];?></td>
    					<td><?php echo $row['sum_netbuy']+$row['sum_promo'];?></td>
    				</tr>
    		<?php 	
    			endforeach;
    		?>
    	
    	</tbody>
 	</table>	
	</body>
</html>
